package com.edu.exam.entity.exampaper.review;

import com.edu.exam.enums.grading.ConfigType;
import com.edu.exam.enums.assessment.generation.Scope;
import com.edu.exam.enums.examination.paper.AlgorithmType;
import com.edu.exam.enums.exampaper.review.ExamPaperCheckTaskStatus;
import com.edu.exam.enums.assessment.technical.CheckType;
import com.edu.exam.enums.assessment.technical.CheckStatus;
import com.edu.exam.enums.assessment.technical.SimilarityLevel;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 试卷查重记录实体类
 *
 * <p>记录试卷查重的详细信息，包括查重任务、相似度计算结果、
 * 状态变更等核心信息。是试卷查重子模块的核心实体。</p>
 *
 * @author 系统生成
 * @version 2.0
 * @since 2025-11-09
 */
@Entity
@Data
@EqualsAndHashCode(callSuper = false)
@EntityListeners(AuditingEntityListener.class)
public class ExamPaperCheckRecord {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 试卷ID
     */
    @Column(name = "paper_id", nullable = false)
    private Long paperId;

    /**
     * 目标试卷ID
     */
    @Column(name = "target_paper_id")
    private Long targetPaperId;

    /**
     * 批量查重任务ID
     */
    @Column(name = "batch_check_task_id")
    private Long batchCheckTaskId;

    /**
     * 查重类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "check_type", nullable = false, length = 20)
    private CheckType checkType;

    /**
     * 查重状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "check_status", nullable = false, length = 20)
    private CheckStatus checkStatus;

    /**
     * 总体相似度
     */
    @Column(name = "overall_similarity", precision = 5, scale = 2)
    private BigDecimal overallSimilarity;

    /**
     * 内容相似度
     */
    @Column(name = "content_similarity", precision = 5, scale = 2)
    private BigDecimal contentSimilarity;

    /**
     * 结构相似度
     */
    @Column(name = "structure_similarity", precision = 5, scale = 2)
    private BigDecimal structureSimilarity;

    /**
     * 题型相似度
     */
    @Column(name = "question_type_similarity", precision = 5, scale = 2)
    private BigDecimal questionTypeSimilarity;

    /**
     * 难度相似度
     */
    @Column(name = "difficulty_similarity", precision = 5, scale = 2)
    private BigDecimal difficultySimilarity;

    /**
     * 知识点相似度
     */
    @Column(name = "knowledge_point_similarity", precision = 5, scale = 2)
    private BigDecimal knowledgePointSimilarity;

    /**
     * 相似度等级
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "similarity_level", length = 20)
    private SimilarityLevel similarityLevel;

    /**
     * 是否超过阈值
     */
    @Column(name = "is_threshold_exceeded")
    private Boolean isThresholdExceeded;

    /**
     * 重复试题数量
     */
    @Column(name = "duplicate_question_count")
    private Integer duplicateQuestionCount;

    /**
     * 总试题数量
     */
    @Column(name = "total_question_count")
    private Integer totalQuestionCount;

    /**
     * 重复率
     */
    @Column(name = "duplication_rate", precision = 5, scale = 2)
    private BigDecimal duplicationRate;

    /**
     * 查重开始时间
     */
    @Column(name = "start_time")
    private LocalDateTime startTime;

    /**
     * 查重结束时间
     */
    @Column(name = "end_time")
    private LocalDateTime endTime;

    /**
     * 执行时长(毫秒)
     */
    @Column(name = "execution_duration")
    private Long executionDuration;

    /**
     * 查重算法版本
     */
    @Column(name = "algorithm_version", length = 50)
    private String algorithmVersion;

    /**
     * 查重参数配置
     */
    @Column(name = "check_config", columnDefinition = "TEXT")
    private String checkConfig;

    /**
     * 详细分析报告
     */
    @Column(name = "detailed_report", columnDefinition = "TEXT")
    private String detailedReport;

    /**
     * 错误信息
     */
    @Column(name = "error_message", columnDefinition = "TEXT")
    private String errorMessage;

    /**
     * 备注信息
     */
    @Column(name = "remarks", length = 500)
    private String remarks;

    /**
     * 创建人ID
     */
    @Column(name = "created_by")
    private Long createdBy;

    /**
     * 更新人ID
     */
    @Column(name = "updated_by")
    private Long updatedBy;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @LastModifiedDate
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

    /**
     * 删除时间
     */
    @Column(name = "deleted_time")
    private LocalDateTime deletedTime;

    /**
     * 删除人ID
     */
    @Column(name = "deleted_by")
    private Long deletedBy;

}